<template>
  <div class="app-container">
    <div class="card-container" v-loading="loading" @click="handleInter(video)">
      <el-row :gutter="20">
        <el-col
          :span="8"
          v-for="video in videoList"
          :key="video.id"
        >
          <el-card shadow="hover" class="card-item">
            <div class="card-header">
              <p>{{ video.name }}</p>

            </div>
            <div class="card-content">
              <p>备注: {{ video.remark || '无' }}</p>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { listVideo, getVideo,listVideoByCId } from "@/api/course/video";

export default {
  name: "Video",
  data() {
    return {
      // 根路径
      baseURL: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 视频表格数据
      videoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        url: null,
        categoryId: null,
        remark: null,
        cId: null
      },
      // 表单参数
      form: {},

    };
  },
  created() {
    // 假设cId是通过路由参数传递的
    if (this.$route.query.cId) {

      this.queryParams.cId = this.$route.query.cId;
    }
    this.getList();
  },
  methods: {
    handleInter(row){
      this.$router.push({path:'/course/s_video?id='+row.id});

    },
    /** 查询视频列表 */
    getList() {
      this.loading = true;
      //listVideoByCId只接受cId作为参数
      console.log(this.queryParams.cId)
      listVideoByCId(this.queryParams.cId).then(response => {
        this.videoList = response.data;
        this.total = this.videoList.length;
        this.loading = false;
        console.log(this.total)
      }).catch(error => {
        console.error('获取视频列表失败:', error);
        this.loading = false;
      });
    }
  }
};
</script>
<style>
.mb8 {
  margin-top: -35px;
}
.card-container{
  text-align: center;
  font-size: 18px;
}
.card-header{
  font-size: 25px;

}
.el-card{
  height: 250px;
  line-height: 45px;
}

.card-item {
  border: 1px solid #d0e6f2; /* 边框颜色 */
  border-radius: 10px; /* 圆角 */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* 阴影效果 */
  transition: transform 0.3s, box-shadow 0.3s; /* 动效 */
  padding: 20px; /* 内容内边距 */
}

.card-item:hover {
  transform: translateY(-5px); /* 悬浮时提升 */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15); /* 悬浮时阴影加深 */
}

.card-header {
  font-size: 28px;
  font-weight: bold;
  color: #007bff; /* 蓝色标题 */
  margin-bottom: 10px;
}

.card-content {
  font-size: 16px;
  color: #4a4a4a; /* 深灰色内容字体 */
  line-height: 1.5;
}

.card-footer {
  text-align: right;
  margin-top: 15px;
}

.el-button {
  background-color: #007bff;
  color: #ffffff;
  border-radius: 5px;
}

.el-button:hover {
  background-color: #0056b3; /* 悬浮时按钮颜色加深 */
}
</style>
